package march.firstmarch21.march02;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class CallDriver {
    public static void main(String[] args) {
        Job job;
        Configuration conf = new Configuration();
        try {
            // 获取job
            job = Job.getInstance(conf);

            // 基础配置
            job.setMapperClass(CallMapper.class);
            job.setReducerClass(CallReducer.class);
            job.setJarByClass(CallDriver.class);
            job.setMapOutputKeyClass(Text.class);
            job.setMapOutputValueClass(CallBean.class);
            job.setOutputKeyClass(NullWritable.class);
            job.setOutputValueClass(CallBean.class);

            // 输入输出文件
            FileInputFormat.setInputPaths(job, new Path("F:\\test\\callInput"));
            FileOutputFormat.setOutputPath(job, new Path("F:\\test\\callOutput"));
            boolean b = job.waitForCompletion(true);
            System.exit(b ? 0 : 1);

        } catch (Exception e){
            e.printStackTrace();
        }
    }
}
